//
//  HaoBaTabbarVC.m
//  HaoBaShengxinEn
//
//  Created by 暗流澎涌 on 2024/6/18.
//

#import "HaoBaTabbarVC.h"
#import "HaoBaFirstHomeVC.h"
#import "HaoBaZiyuanHomeVC.h"
#import "HaoBaLeasonHomeVC.h"
#import "HaoBaMemoryHomeVC.h"
#import "HaoBaMeHomeVC.h"
//#define mainColor [UIColor colorWithRed:(((0xFFFB8C & 0xFF0000) >> 16))/255.0 green:(((0xFFFB8C &0xFF00) >>8))/255.0 blue:((0xFFFB8C &0xFF))/255.0 alpha:1.0]
#define mainColor [UIColor redColor]

#define defaultColor [UIColor colorWithRed:(((0xFFFFFF & 0xFF0000) >> 16))/255.0 green:(((0xFFFFFF &0xFF00) >>8))/255.0 blue:((0xFFFFFF &0xFF))/255.0 alpha:1.0]

@interface HaoBaTabbarVC ()

@end

@implementation HaoBaTabbarVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setChildrenVc];
}
-(void)setChildrenVc{
    
    // 创建渐变层
//    CAGradientLayer *gradientLayer = [CAGradientLayer layer];
//    gradientLayer.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 83); // 设置渐变层的大小
////    gradientLayer.colors = @[(id)[UIColor colorWithRed:158.0/255 green:218.0/255 blue:255.0/255 alpha:1].CGColor, (id)[UIColor colorWithRed:0/255 green:116.0/255 blue:255.0/255 alpha:1].CGColor]; // 设置渐变色
//    gradientLayer.colors = @[[UIColor whiteColor] ,[UIColor whiteColor]];
////    gradientLayer.colors = @[(id)[UIColor redColor].CGColor, (id)[UIColor blueColor].CGColor]; // 设置渐变色
//
//    // 创建图片
//    UIGraphicsBeginImageContext(gradientLayer.frame.size);
//    [gradientLayer renderInContext:UIGraphicsGetCurrentContext()];
//    UIImage *gradientImage = UIGraphicsGetImageFromCurrentImageContext();
//    UIGraphicsEndImageContext();
// 
//    if (@available(iOS 16.0, *)) {
//        //
////        [self.tabBar setBackgroundColor: [UIColor colorWithRed:80.0/255 green:153.0/255 blue:248.0/255 alpha:1]];
//        [self.tabBar setBackgroundColor:[UIColor whiteColor]];
////        self.tabBar.unselectedItemTintColor  = [UIColor whiteColor];
//    }else{
//
//        self.tabBar.backgroundImage = gradientImage;
//    }
    [self.tabBar setBackgroundColor:[UIColor whiteColor]];
    HaoBaFirstHomeVC * firVc=[[HaoBaFirstHomeVC alloc]init];
    UINavigationController * fitNa=[[UINavigationController alloc]initWithRootViewController:firVc];
    fitNa.tabBarItem.title=@"新概念英语";
    fitNa.tabBarItem.image=[[UIImage imageNamed:@"haoba_1_1"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
    fitNa.tabBarItem.selectedImage=[[UIImage imageNamed:@"haoba_1"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

    [fitNa.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:mainColor,NSForegroundColorAttributeName,nil]  forState:UIControlStateSelected];
    [fitNa.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:defaultColor,NSForegroundColorAttributeName,nil]  forState:UIControlStateNormal];
    [self addChildViewController:fitNa];
//
//
    HaoBaZiyuanHomeVC * thrVc=[[HaoBaZiyuanHomeVC alloc]init];
    UINavigationController * thrNa=[[UINavigationController alloc]initWithRootViewController:thrVc];
    thrNa.tabBarItem.title=@"免费资源";
    thrNa.tabBarItem.image=[UIImage imageNamed:@"haoba_1_2"];
    thrNa.tabBarItem.selectedImage=[[UIImage imageNamed:@"haoba_2"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

    [thrNa.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:mainColor,NSForegroundColorAttributeName,nil]  forState:UIControlStateSelected];
    [thrNa.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:defaultColor,NSForegroundColorAttributeName,nil]  forState:UIControlStateNormal];
    [self addChildViewController:thrNa];
    
    HaoBaLeasonHomeVC * secVc=[[HaoBaLeasonHomeVC alloc]init];
    UINavigationController * secNa=[[UINavigationController alloc]initWithRootViewController:secVc];
    secNa.tabBarItem.title=@"听力";
    secNa.tabBarItem.image=[UIImage imageNamed:@"haoba_1_3"];
    secNa.tabBarItem.selectedImage=[[UIImage imageNamed:@"haoba_3"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

    [secNa.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:mainColor,NSForegroundColorAttributeName,nil]  forState:UIControlStateSelected];
    [secNa.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:defaultColor,NSForegroundColorAttributeName,nil]  forState:UIControlStateNormal];
    
    [self addChildViewController:secNa];

   

    HaoBaMemoryHomeVC * fourVcs=[[HaoBaMemoryHomeVC alloc]init];
    UINavigationController * fourNa=[[UINavigationController alloc]initWithRootViewController:fourVcs];
    fourNa.tabBarItem.title=@"记忆锻炼";
    fourNa.tabBarItem.image=[UIImage imageNamed:@"haoba_1_4"];
    fourNa.tabBarItem.selectedImage=[[UIImage imageNamed:@"haoba_4"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

    [fourNa.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:mainColor,NSForegroundColorAttributeName,nil]  forState:UIControlStateSelected];
    [fourNa.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName,nil]  forState:UIControlStateNormal];
    [self addChildViewController:fourNa];

    
    
    HaoBaMeHomeVC * fVc=[[HaoBaMeHomeVC alloc]init];
    UINavigationController * fNa=[[UINavigationController alloc]initWithRootViewController:fVc];
    fNa.tabBarItem.title=@"我的";
    fNa.tabBarItem.image=[UIImage imageNamed:@"haoba_1_5"];
    fNa.tabBarItem.selectedImage=[[UIImage imageNamed:@"haoba_5"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

    [fNa.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:mainColor,NSForegroundColorAttributeName,nil]  forState:UIControlStateSelected];
    [fNa.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:defaultColor,NSForegroundColorAttributeName,nil]  forState:UIControlStateNormal];
    [self addChildViewController:fNa];
    
}


@end
